home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bluep.swf / scripts / __Packages / DataObject.as < prev    next >
Text File  |  2013-04-24  |  5KB  |  165 lines

  1. class DataObject
  2. {
  3.    function DataObject()
  4.    {
  5.       var _loc3_ = this.RandNum(55,66);
  6.       this.arrElements = new Array(_loc3_);
  7.       var _loc2_ = 0;
  8.       while(_loc2_ < _loc3_)
  9.       {
  10.          this.arrElements[_loc2_] = 0;
  11.          _loc2_ = _loc2_ + 1;
  12.       }
  13.       this.indexOne = -1;
  14.       this.indexTwo = -1;
  15.    }
  16.    function Set(dataValue)
  17.    {
  18.       var _loc6_ = Math.round(Math.random() * dataValue);
  19.       var _loc7_ = dataValue - _loc6_;
  20.       this.indexOne = this.RandNum(0,this.arrElements.length - 4);
  21.       this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
  22.       if(this.indexOne == this.indexTwo)
  23.       {
  24.          if(this.indexOne == this.arrElements.length - 1)
  25.          {
  26.             this.indexTwo = this.indexOne - 1;
  27.          }
  28.          else
  29.          {
  30.             this.indexTwo = this.indexOne + 1;
  31.          }
  32.       }
  33.       var _loc5_ = dataValue / (this.arrElements.length - 2);
  34.       var _loc4_ = dataValue;
  35.       var _loc9_ = this.arrElements.length;
  36.       var _loc2_ = 0;
  37.       while(_loc2_ < this.arrElements.length)
  38.       {
  39.          if(_loc2_ == this.indexOne)
  40.          {
  41.             this.arrElements[_loc2_] = _loc6_;
  42.          }
  43.          else if(_loc2_ == this.indexTwo)
  44.          {
  45.             this.arrElements[_loc2_] = _loc7_;
  46.          }
  47.          else
  48.          {
  49.             var _loc3_ = 0;
  50.             if(_loc4_ > 0)
  51.             {
  52.                _loc3_ = Math.round(Math.random() * _loc5_ + _loc5_ * 0.5);
  53.                if(_loc3_ > _loc4_)
  54.                {
  55.                   _loc3_ = _loc4_;
  56.                }
  57.                if(_loc2_ == this.arrElements.length - 1)
  58.                {
  59.                   _loc3_ = _loc4_;
  60.                }
  61.                _loc4_ -= _loc3_;
  62.             }
  63.             this.arrElements[_loc2_] = _loc3_;
  64.          }
  65.          _loc2_ = _loc2_ + 1;
  66.       }
  67.    }
  68.    function mSet(dataValue)
  69.    {
  70.       var _loc7_ = 0;
  71.       while(_loc7_ < 10)
  72.       {
  73.          var _loc5_ = Math.round(Math.random() * dataValue);
  74.          var _loc8_ = dataValue - _loc5_;
  75.          this.indexOne = this.RandNum(0,this.arrElements.length - 4);
  76.          this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
  77.          if(this.indexOne == this.indexTwo)
  78.          {
  79.             if(this.indexOne == this.arrElements.length - 1)
  80.             {
  81.                this.indexTwo = this.indexOne - 1;
  82.             }
  83.             else
  84.             {
  85.                this.indexTwo = this.indexOne + 1;
  86.             }
  87.          }
  88.          var _loc4_ = dataValue / (this.arrElements.length - 2);
  89.          var _loc10_ = dataValue;
  90.          var _loc9_ = this.arrElements.length;
  91.          var _loc2_ = 0;
  92.          while(_loc2_ < this.arrElements.length)
  93.          {
  94.             if(_loc2_ == this.indexOne)
  95.             {
  96.                this.arrElements[_loc2_] = _loc5_;
  97.             }
  98.             else if(_loc2_ == this.indexTwo)
  99.             {
  100.                this.arrElements[_loc2_] = _loc8_;
  101.             }
  102.             else
  103.             {
  104.                var _loc3_ = 0;
  105.                _loc3_ = Math.round(Math.random() * (_loc4_ * 1.23) + _loc4_ * 0.75);
  106.                this.arrElements[_loc2_] = _loc3_;
  107.             }
  108.             _loc2_ = _loc2_ + 1;
  109.          }
  110.          if(this.Get() == -1)
  111.          {
  112.             break;
  113.          }
  114.          _loc7_ = _loc7_ + 1;
  115.       }
  116.    }
  117.    function Get()
  118.    {
  119.       var _loc3_ = 0;
  120.       var _loc4_ = 0;
  121.       var _loc2_ = 0;
  122.       while(_loc2_ < this.arrElements.length)
  123.       {
  124.          if(_loc2_ == this.indexOne)
  125.          {
  126.             _loc3_ += this.arrElements[_loc2_];
  127.          }
  128.          else if(_loc2_ == this.indexTwo)
  129.          {
  130.             _loc3_ += this.arrElements[_loc2_];
  131.          }
  132.          else
  133.          {
  134.             _loc4_ += this.arrElements[_loc2_];
  135.          }
  136.          _loc2_ = _loc2_ + 1;
  137.       }
  138.       if(_loc3_ == _loc4_)
  139.       {
  140.          return _loc3_;
  141.       }
  142.       return -1;
  143.    }
  144.    function Store()
  145.    {
  146.       var _loc2_ = this.arrElements.slice();
  147.       _loc2_.splice(2,0,this.indexOne);
  148.       _loc2_.splice(7,0,this.indexTwo);
  149.       return _loc2_;
  150.    }
  151.    function Load(originalArray)
  152.    {
  153.       this.indexOne = originalArray[2];
  154.       this.indexTwo = originalArray[7];
  155.       delete this.arrElements;
  156.       this.arrElements = originalArray.slice();
  157.       this.arrElements.splice(7,1);
  158.       this.arrElements.splice(2,1);
  159.    }
  160.    function RandNum(minVal, maxVal)
  161.    {
  162.       return Math.round(Math.random() * (maxVal - minVal)) + minVal;
  163.    }
  164. }
  165.